import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import path from 'path';

// https://vitejs.dev/config/
export default defineConfig({
  base: '/szjc-ai-web',
  // base: './',
  plugins: [vue()],
  build: {
    minify: 'terser',
    rollupOptions: {
      output: {
        manualChunks: {
          vue: ['vue'],
          'vue-router': ['vue-router'],
          lodash: ['lodash'],
          pinia: ['pinia'],
          'element-plus': ['element-plus'],
          axios: ['axios'],
          dayjs: ['dayjs'],
          'vue-i18n': ['vue-i18n'],
          'element-plus-icon': ['@element-plus/icons-vue'],
        },
        experimentalMinChunkSize: 50000,
      },

      treeshake: {
        preset: 'recommended',
      },
    },
    // terserOptions: { compress: { drop_console: true, drop_debugger: true } },
  },
  server: {
    https: false,
    port: 8822,
    host: '0.0.0.0',
    proxy: {
      '/api': {
        target: 'http://192.168.1.28:18888',
        // target: 'http://192.168.16.104:18888',
        changeOrigin: true,
        rewrite: path => path.replace(/^\/api/, ''),
      },
    },
  },

  resolve: {
    alias: { '@': path.resolve(__dirname, './src') },
  },
});
